﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Tulde.Windows.Music.Mp3Tunes
{
    /// <summary>
    /// 
    /// </summary>
    public enum AlbumArtSizeOptions
    {
        xsmall, small, medium, large
    }
    /// <summary>
    /// When downloading album and track info, usually  an album art url will exist. However, sometimes you may want to get a different sized album art url.
    /// This service allows you to create an album art url with varying sizes.
    /// 
    /// 
    /// </summary>
    public class AlbumArtService : BaseDataService<LockerDataOperations>
    {
        protected override string BaseUrl
        {
            get {
                return "http://content.mp3tunes.com/storage/";
            }
        }
        protected override object DeserializeResult(string result)
        {
            throw new NotImplementedException();
        }
        protected override string AppendParametersToUrl(string url, string operation, ServiceParameters parameters)
        {
            List<string> parametersList = new List<string>();
            parameters.Remove(Constants.Output);
            foreach (string key in parameters.Keys)
            {
                parametersList.Add(String.Format("{0}={1}", key, parameters.GetParameter(key)));
            }
            if (parameters == null || !parameters.Keys.Any())
            {
                return url;
            }
            else
            {
                return url + operation +"/"+parameters.Remove(Constants.ParameterAlbum) + "?" + String.Join("&", parametersList.ToArray());
            }
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public class AlbumArtServiceParameters : ServiceParameters
    {
        public string AlbumServiceKey
        {
            get
            {
                return this.GetParameter(ServiceKeys.album_id.ToString());
            }
            set
            {
                this.SetParameter(ServiceKeys.album_id.ToString(), value);
            }
        }
        public AlbumArtSizeOptions Size
        {
            get
            {
                return (AlbumArtSizeOptions)Enum.Parse(typeof(AlbumArtSizeOptions), this.GetParameter("size"));
            }
            set
            {
                this.SetParameter("size", value.ToString());
            }
        }
        public AlbumArtServiceParameters()
        {
            //this.Size = AlbumArtSizeOptions.medium;
            this.SessionId = SecurityProvider.Token.SessionID;
        }
    }
}
